Lab 2 – Basic Stamp II – Building a Digital Multimeter

Assigned: Feb 28th 2002 Due: March. 21st 2002

(This file is also available here in PDF form)

Motivation

 

The physical world remains fundamentally analog while the computer is primarily a digital device. Hence, conversion between analog and digital domains, appropriately termed Analog to Digital Conversion (ADC) and Digital to Analog Conversion (DAC), is essential to permit operation by computers on the physical world and this second project focuses primarily on such conversions. For example, sensors typically output an analog signal (voltage or resistance) proportional to the quantity being measured; and actuator outputs are designed to be proportional to analog control signals (voltage/current) which must be provided by the computer. (In subsequent labs we will look at the actual sensors which transduce physical quantities into electrical signals and the actuator technology which transduce the electrical signals to take actions on the physical world). To motivate and understand this process, we will be implementing the following “products” that will be of use to us in subsequent labs:

A)      A Digital Ohmmeter (which you can implement using the BS2 RCTIME command) to measure resistance;

B)      A Digital Voltmeter (for which you will use an ADC chip, the ADC0831) to measure voltages;

C)      An R-2R ladder based Digital-to-Analog Converter (R2RDAC); and

D)      A Pulse Width Modulation based Digital-to-Analog Converter (PWMDAC).

 

Goals:

At the end of this exercise you will become familiar with:

1.       Digital measurement of analog voltages and resistances and digital control of analog voltage output.

2.       Interfacing an analog-to-digital converter (which uses a synchronous serial input/output interface).

3.       Performing basic floating point operations using only integer arithmetic.

4.       Creation and control of a basic Digital to Analog Converter using either an R-2R ladder or PWM.

5.       Calibration techniques for resistances, A/D and D/A converters.

 

Implementation Details:

The following steps are to be implemented using the StampWorks kit:

A.      Digital Ohmmeter

Construct a simple digital Ohmmeter (using the circuit shown in Figure 1) to measure the value of the unknown resistance “R” and display the value on your LCD display. The Ohmmeter mode is activated by pressing Button 1 on the keypad and is deactivated when any of the other buttons are pressed. Pressing Button 1 again (at any time in the process) initiates a fresh measurement and updates the value of the measured resistance on the LCD display. Refer to the use of the RCTIME command from your Stamp Manual for further details.

 

Obviously, your ohmmeter will work well for a given range of resistances. For your report, determine that range of operation and then by selecting a series of known resistances within that range and measuring the values read in by your created Ohmmeter. Use a linear fit of the data to obtain the calibration constants for your ohmmeter so as to improve its accuracy. Your Ohmmeter must be capable of reading any arbitrary resistance (between 1K to 10K) during the demonstration.  (DEMO 1)

Figure  1: An RC network connected to a pin of the Basic Stamp


 

Figure  2: Voltage Divider using a Potentiometer   


 

B.      Digital Voltmeter

1.       Construct a voltage divider on your breadboard using the supplied potentiometer and the +5V supply and ground as shown in Figure 2.

2.       Interface the 8 bit, serial A/D converter (ADC0831) to the Basic Stamp (see application note in Stamp manual [Pages 353-60] and the discussions on SHIFTIN and SHIFTOUT [Pages 330-35, 439-42]) and measure the variable voltage provided by the Voltage divider created in Step 1.

      ADC0831 Specs: http://www.national.com/pf/AD/ADC0831.html

 

This looks like (and is) a reasonably trivial step but will take you the longest time to finish. So please plan on spending time reading the relevant Stamp literature and the ADC0831 literature.

 

3.       Pressing Button 2 on the keypad sets the system into the Digital Voltmeter mode. Convert the obtained binary values from the ADC into a floating point voltage level (between 0 and 5) and display both on the LCD screen -- Binary value on line 1 and the converted voltage value (to three decimal places) on line 2 of your display. (DEMO 2)

 

4.       For your report, verify the measured voltages displayed on the LCD screen using the desktop Digital Volt Meter (DVM). Create a calibration table and chart for the A/D converter (in increments of 0.5V) with the following entries:

 

Desktop

Voltmeter

Reading

     Binary

 A/D value

LCD Display Reading

0.000V

000000000001

0.001

0.50V

000010111110

0.51

     .

              .

   .

5.000V

111111111010

4.995

 

  Table 1: Calibration Table for the ADC (Sample)                                      Figure  3: Calibration Chart for the ADC (Sample)              

 

What can you say about the linearity of this ADC? Please also note down other important characteristics of this ADC in your report.                                                                                                                                   

 

C.      Digitally Controlled Voltage Source using an R-2R Ladder Network (R2RDAC)

1.       Create an R-2R ladder network DAC (as discussed in class) and interface its output to a LED and the ADC as shown in the Figure 4 below.

Figure  4 : R-2R ladder without Voltage Follower  

 

2.       Note: Figure 4 depicts the implementation of a 4-bit R-2R ladder network where by outputting a series of LOWs (0) and HIGHs (1) on the output pins P4-P7 one can create the appropriate output voltage levels (Resolution=4bits). The LED serves as a load on the DAC circuitry while the ADC (set up in the previous stage) serves to measure the output voltage levels. In your system you will use an integrated R-2R network which takes the form of a 16 pin DIP chip (4116R-R2R-102). Set up the system so that pressing Button 3 increments the output of the DAC while Button 4 decrements the output of the DAC. Create a table and note down the values of the output voltage from this DAC for the range of 8-bit digital output values (from $00 to $FF in increments of 16).  R-2R Network Specifications: http://www.bourns.com/pdf/r2r.pdf

 

3.       Augment the setup in Step 1 by adding the voltage follower circuit as shown in Figure 4 using one of the channels of the LM358 shown in Figure 5. Now create a similar calibration table to correlate the output digital levels to the actual values measured by the ADC. (DEMO 3)

           LM358 Specs: On the National Semiconductor Web Site http://www.national.com/pf/LM/LM358.html

 

Figure  5 : R-2R ladder with Voltage Follower       

 

 

Reporting:

Provide a self-standing document, which could be used as an “Application Note” which describes and explains your system and would enable someone else to replicate your work. Document your system with a circuit diagram, list of components, and parts cost estimate. Include a listing of your program with thorough comments  Additionally, please make sure you include a brief discussion of the following:

·         The principle, circuitry and operation of the Ohmmeter mode which uses the RCTIME command. How accurate are these results compared with the DVM measured values ? Identify the possible sources for the error in measurement of resistance between the desktop DVM and your newly created multimeter !

·         The implementation and operation and limitations of the voltmeter.  What is the maximum sampling rate for the ADC?  How accurate is the voltage and resistance measurement ? Other comments ?

·        The implementation and operation of the DAC, and resolution/accuracy/other features of the system.